package connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnection 
{
		Connection con= null;
		
		public Connection getNewConnection()
		{
			try 
			{
				Class.forName("com.mysql.jdbc.Driver");
			}
			catch (ClassNotFoundException e) 
			{
				e.printStackTrace();
			}
			
			try 
			{
				 con= DriverManager.getConnection("jdbc:mysql://localhost:3306/boa", "root","");
			}
			catch (SQLException e) 
			{
				//e.printStackTrace();
				
			}
			
			if(con!=null)
			{
				System.out.println("You r connected with database");
			}
			else
			{
				System.out.println("connection error");
			}
			return con;
		}
		
		public void closeConnection()
		{	
			try 
			{
				con.close();
			} 
			catch (SQLException e) 
			{
				e.printStackTrace();
			}
		}
}
